<template>
  <div class="card-container">
    <!-- 搜索区域 -->
    <div class="search-container">
      <span class="search-label">车牌号码：</span>

      <el-input v-model="payMentList.carNumber " clearable placeholder="请输入车牌号码" class="search-main" />
      <span class="search-label">缴纳状态：</span>
      <el-select v-model="payMentList.paymentStatus " placeholder="未选择">
        <el-option v-for="item in payStatusList" :key="item.id" :value="item.id" :label="item.name" />
      </el-select>

      <el-button type="primary" class="search-btn" @click="searchList()">查询</el-button>

    </div>
    <!-- 表格区域 -->
    <div class="table">
      <el-table style="width: 100%" :data="payMentArr">
        <el-table-column type="index" label="序号" />
        <el-table-column label="车牌号码" prop="carNumber" />
        <el-table-column label="收费类型" prop="chargeType">
          <template v-slot="scope">
            {{ scope.row.chargeType === "temp" ? '临时停车' : '月卡' }}
          </template>
        </el-table-column>
        <el-table-column label="停车总时长" prop="parkingTime" />
        <el-table-column label="缴纳费用（元）" prop="actualCharge" />
        <el-table-column label="缴纳状态" prop="paymentStatus">
          <template v-slot="scope">
            {{ scope.row.paymentStatus === 0 ? '未缴纳' : '已缴纳' }}
          </template>
        </el-table-column>
        <el-table-column label="缴纳方式" prop="paymentMethod">
          <template v-slot="scope">
            {{ scope.row.paymentMethod === "Alipay" ? '支付宝' : '--' }}
          </template>
        </el-table-column>
        <el-table-column label="缴纳时间" prop="paymentTime" />

      </el-table>

    </div>

    <div class="page-container">
      <el-pagination
        layout="total, prev, pager, next"
        :total="total"
        @current-change="pageChange"
      />
    </div>

  </div>

</template>

<script>
import { getPaymentAPI } from '@/api/carpay'
export default {
  data() {
    return {
      total: 0,
      payMentArr: [],
      payMentList: {
        page: 1,
        pageSize: 10,
        carNumber: '',
        paymentStatus: ''

      },
      payStatusList: [
        {
          id: 0,
          name: '未缴纳'
        },
        {
          id: 1,
          name: '已缴纳'
        },
        {
          id: null,
          name: '全部'
        }
      ]
    }
  },
  created() {
    this.getPayMentList()
  },
  methods: {
    async  getPayMentList() {
      const res = await getPaymentAPI(this.payMentList)
      console.log(res)
      this.payMentArr = res.data.rows
      this.total = res.data.total
    },
    pageChange(page) {
      this.payMentList.page = page
      this.getPayMentList()
    },
    async searchList() {
      await this.getPayMentList()
      this.payMentList.paymentStatus = ''
      this.payMentList.carNumber = ''
    }
  }
}
</script>

<style lang="scss" scoped>
.card-container {
  padding: 20px;
  background-color: #fff;
}

.search-container {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgb(237, 237, 237, .9);
  padding-bottom: 20px;
  .search-main {
    width: 220px;
    margin-right: 10px;
  }
  .search-btn{
    margin-left:20px;
  }
}
.create-container{
  margin: 10px 0px;
}
.page-container{
  padding:4px 0px;
  text-align: right;
}
.form-container{
  padding:0px 80px;
}
</style>

